/* Copyright 2011 Elektrobit Wireless Communications Oy (EB)


  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 2 as 
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License along
  with this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


 *All rights reserved 
 *Version:Elektrobit_Qt_1.0.0_20110305 */


import Qt 4.7
import "script/script.js" as Script
import "qmlItem" 1.0

Item {
    id: screen
    width: 640; height: 360;
    Image {
        id: backgroundImage
        anchors.fill: parent;
        source: Script.sysPath("images/sys/back_img.png")
    }

    Image
    {
        id: imageBill
        x: 5; y: 25
        width: 184; height: 184
        source: Script.sysPath(getBillImagePath())
    }
    Image
    {
        id: imageDetail
        x: 5; y: 225
        width: 240; height: 75
        source: Script.sysPath(getDetailImagePath())
    }

    Image
    {
        id: imageReturn
        property bool pressed: false
        x: 550; y: 210
        width: 56; height: 56
        source: pressed ? Script.sysPath("images/sys/movie_detail_btn_back.png") :
                Script.sysPath("images/sys/movie_detail_btn_back.png")

        MouseArea {
            anchors.fill: parent
                onPressed: {imageReturn.pressed = true; }
            onReleased: {imageReturn.pressed = false; onIconClick("return")}
        }
    }

    Image
    {
        id: imagePlayer
        property bool pressed: false
        x: 550; y: 260
        width: 56; height: 56

        source: pressed ? Script.sysPath("images/sys/movie_detail_btn_play.png") :
                Script.sysPath("images/sys/movie_detail_btn_play.png")

        MouseArea {
            anchors.fill: parent
                onPressed: {imagePlayer.pressed = true; }
            onReleased: {imagePlayer.pressed = false; onPlayButtonClick(musics.currentIndex);}
        }
    }

    ListView {
        x: 300; y: 50;
        width: 240; height: 350

        id:musics
        Component {
            id: contentDelegate
            Rectangle {
                height: 40
                width: musics.width
                color: "black"
                Text {
                    anchors.fill: parent
                    id: musicName
                    text: name
                    color: index == musics.currentIndex? "red" : "white"
                    font.pixelSize: 16
                }

                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        console.log("index:", index);
                        if(index == musics.currentIndex) {
                            onPlayButtonClick(musics.currentIndex);
                        }else {
                            musics.currentIndex = index;
                        }
                    }
                }

            }
        }

        //highlightRangeMode: ListView.StrictlyEnforceRange
        model:  musicList
        delegate: contentDelegate
        focus: true
    }
}

